<template>
  <div class="login">
    <CanvasImage class="login-canvas" :src="loginBg" />
    <section class="login-logo">
      <CanvasImage class="logo-img" :src="policeBadge" />
      <!-- <img src="@/assets/images/police_badge.png" alt="app_logo"> -->
      <h1>{{ APP_NAME }}</h1>
    </section>
    <main class="login-form">
      <h2 class="login-form-title">登录</h2>
      <el-form class="login-form-main" ref="formRef" :model="formData" label-position="top">
        <el-form-item label="警号" prop="accont">
          <el-input v-model="formData.accont" :prefix-icon="User"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="formData.password" :prefix-icon="Lock" type="password" show-password></el-input>
        </el-form-item>
        <!-- <el-form-item>
          <div style="width: 100%; display: flex; justify-content: space-between;">
            <el-checkbox v-model="rememberMe">记住密码</el-checkbox>
            <el-button type="primary" link>忘记密码？</el-button>
          </div>
        </el-form-item> -->
        <el-form-item>
          <el-button class="login-btn" type="primary" @click="onSubmit">登录</el-button>
        </el-form-item>
      </el-form>
    </main>
    <footer class="login-footer">
      <span>管理员：xxx（基础管控中心） 173xxxx6816</span>
      <span>Copyright © 2025 重庆市公安局江北区分局</span>
    </footer>
  </div>
</template>

<script setup>
import { ref, onMounted, useTemplateRef, reactive } from 'vue';
import { User, Lock } from '@element-plus/icons-vue'
import { APP_NAME } from '@/config';
import loginBg from '@/assets/images/login_bg.png';
import policeBadge from '@/assets/images/police_badge.png';

const formData = reactive({});
const rememberMe = ref(false);
</script>

<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  position: relative;

  &-logo {
    position: absolute;
    top: 5%;
    left: 3%;
    cursor: default;
    display: flex;
    align-items: center;

    .logo-img {
      height: 58px;
      margin-right: var(--ycy-gap-small);
    }

    h1 {
      font-weight: bold;
      color: var(--el-text-color-primary);
      font-size: 36px;
    }
  }

  &-form {
    position: absolute;
    left: 10%;
    top: 30%;
    width: 400px;
    padding: calc(var(--ycy-gap-base) * 2);
    border-radius: calc(var(--el-border-radius-base) * 2);
    // background-color: var(--el-fill-color-extra-light);
    background-color: #f9fafe;
    box-shadow: -6px 6px 15px 0px rgba(58, 134, 244, 0.10);

    .login-form-title {
      font-size: 28px;
      font-weight: 500;
      letter-spacing: 6px;
      text-align: center;
      color: #2A1E17;
    }

    .login-form-main {
      margin-top: var(--ycy-gap-large);
      
      .el-form-item {
        margin-bottom: 22px;

        :deep(.el-form-item__label) {
          color: #2A1E17;
          font-weight: 500;
          font-size: var(--el-font-size-medium);
        }
      }

      .el-input {
        height: 46px;
        font-size: var(--el-font-size-medium);

        :deep(.el-input__wrapper) {
          // box-shadow: none;

          .el-input__icon {
            font-size: var(--el-font-size-large);
          }
        }
      }

      :deep(.el-checkbox__inner) {
        width: 18px;
        height: 18px;

        &::after {
          top: 3px;
          left: 6px;
        }
      }

      .login-btn {
        width: 100%;
        height: 46px;
        letter-spacing: 4px;
        font-size: var(--el-font-size-medium);
        box-shadow: 0px 4px 10px 0px rgba(58, 134, 244, 0.5);;
        transition: box-shadow 0.3s;

        &:hover {
          background-color: var(--el-color-primary);
          border-color: var(--el-color-primary);
          box-shadow: 0px 4px 25px 0px rgba(58, 134, 244, 0.5);
        }
      }
    }
  }

  &-footer {
    position: absolute;
    bottom: 3%;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--el-font-size-small);
    color: var(--el-text-color-secondary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    row-gap: var(--ycy-gap-small);
  }

  &-canvas {
    width: 100%;
    height: 100%;
    min-width: 1350px;
    object-fit: cover;
  }
}
</style>